package com.company.java.basic.day01;
/*
算数运算符
+ - * / %(模运算)
模运算：被模数%模数  结果的正负只看被模数的符号
 — 也有转换符号的作用
 自增
 ++、--
 */
public class Day01_Arithmetic {
    public static void main(String[] args) {
        int a1 = 10;
        int a2 = 6;
        System.out.println("a1+a2="+(a1+a2));
        System.out.println("a1%a2="+a1%a2);
        System.out.println("------------");
        System.out.println("5%2="+5%2);
        System.out.println("5%-2="+5%-2);
        System.out.println("-5%2="+-5%2);
        System.out.println("-5%-2="+-5%-2);
        System.out.println("------------");
        int b1 = -1;
        int b2 = 1;
        System.out.println(-(b1));
        System.out.println(-(b2));
        System.out.println("------------");
        int c1 = 1;
        int c2 = c1++;
        //看运算符的顺序，将c1赋给c2后再自增，等号后，先变量，再+号
        //自增步骤
        //1、将c1取出放入‘操作数栈’
        //2、c1自增
        //3、将‘操作数栈’的c1赋值c2
        System.out.println("c1="+c1);
        System.out.println("c1="+c2);
        int d1 = 1;
        int d2 = ++d1;
        //自增步骤
        //1、d1自增
        //2、将d1取出放入‘操作数栈’
        //3、将‘操作数栈’的c1赋值c2
        System.out.println("d1="+d1);
        System.out.println("d1="+d2);
        System.out.println("------------");
        int b = 1;
        int c = 2;
        int d = b++ + ++b + b++ * c++;
        System.out.println("d="+d);
        System.out.println("------------");
        int e = 1;
        int f = 2;
        //可将输出内容看作一个整体如 k= b++ + ++b + b++ * c++
        //来计算
        System.out.println(b++ + ++b + b++ * c++);
        System.out.println("------------");
        //求三位数百、十、个位数的数字
        int num = 857;
        //个位
        int bai = num/100;
        int shi = num/10%10;
        int ge = num%10;
        System.out.println(bai);
        System.out.println(shi);
        System.out.println(ge);
        System.out.println("------------");
        //注意char的运算(万国码)
        System.out.println('a'+1+"Hello");

    }

}
